package worldofbearcraft;


public class Enemy {
	private boolean _death = false;
	private int _hitPoints;
	private int _armorClass;
	private int _attackPower;
	private int _initiative;
	private String _name;
	public Enemy(String name, int hp, int ac, int ap)
	{
		_name = name;
		_hitPoints = hp;
		_armorClass = ac;
		_attackPower = ap;
		_initiative = Dice.initRoll();
	}
	
	public void DisplayInfo()
	{		
		System.out.println("Name: " + _name);
		System.out.println("HP:" + _hitPoints);
	}
	
	public void Attack(Player p)
	{
		int _dmg = Dice.dmgRoll(6, 1 );
		int _crit = _dmg * 2;
		int _atk = Dice.atkRoll();
		boolean hit = false;
		
		if (_atk == 20)
			_dmg = _crit;
			
		int _atkModified = _atk + _attackPower;
		
		
		if (_atkModified >= p.getArmorClass())
			hit = true;
		else
			hit = false;
		
		if (hit == true){
			
		
			System.out.println("The Enemy has hit the player for " + _dmg +"damage.");
			p.setHitPoints(p.getHitPoints()- _dmg);
			if (p.getHitPoints() <= 0)
				{
					System.out.println ("The Enemy " +_name +" has slain " +p.getName()+" !");
					p.DieDramatically();
				}
			else
				System.out.println ("Players remaining HP is " +p.getHitPoints());
		}
		else
		{
		System.out.println (_name +" has missed" +p.getName() +", with an modified attack value of : " +_atkModified);
		System.out.println ( p.getName() +"'s total remaining HP is " +p.getHitPoints());
		}
	}		
			public boolean getDeath() { return _death; }
			public int getHitPoints(){ return _hitPoints; }
			public int getArmorClass() { return _armorClass; }
			public void setHitPoints(int value){_hitPoints = value;}
			public String getName(){ return _name; }
			public int getInitiative(){ return _initiative; }
			public void DieDramatically(){ _death = true; }
	}



